﻿using NationalD3.Domain.Base;
using NationalD3.Domain.ValueObjects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NationalD3.Domain.Entities
{
    /// <summary>
    /// 学生实体类，此类为一个聚合根（采用充血模型）
    /// </summary>
    public class Student : AggregateRoot
    {
        /// <summary>
        /// 无参构造函数，用于EF拿到数据后生成实体对象
        /// </summary>
        protected Student()
        {
        }

        /// <summary>
        /// 重载构造函数（有参），用于初始化实体对象
        /// </summary>
        /// <param name="id"></param>
        /// <param name="name"></param>
        /// <param name="email"></param>
        /// <param name="phone"></param>
        /// <param name="birthDate"></param>
        /// <param name="address"></param>
        public Student(Guid id, string name, string email, string phone, DateTime birthDate, Address address)
        {
            Id = id;
            Name = name;
            Email = email;
            Phone = phone;
            BirthDate = birthDate;
            CreatedTime = DateTime.Now;
            Address = address;
        }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; private set; } //set方法设置为private私有，防止从外部设置属性
        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email { get; private set; }
        /// <summary>
        /// 手机
        /// </summary>
        public string Phone { get; private set; }
        
        /// <summary>
        /// 生日
        /// </summary>
        public DateTime BirthDate { get; private set; }

        /// <summary>
        /// 创建日期
        /// </summary>
        public DateTime CreatedTime { get; private set; }

        /// <summary>
        /// 户籍地址(这是一个值对象)
        /// </summary>
        public Address Address { get; private set; }


        /// <summary>
        /// 创建对象
        /// </summary>
        /// <returns></returns>
        public Student Create()
        {
            this.Id = Guid.NewGuid();
            this.CreatedTime = DateTime.Now;
            return this;
        }
    }
}
